1
'****************************** Module Header ******************************'
2 ' Module Name: TPHClass.vb
3 ' Project: VBEFEntityDataModel
4 ' Copyright (c) Microsoft Corporation.
6 ' This example demonstrates how to establish table per hierarchy inheritance.
7 ' A table-per-type model is a way to model inheritance where each entity is
8 ' mapped to a distinct table in the store. Then it shows how to query a list
9 ' of people, get the corresponding properties of Person, Student and
12 ' This source is subject to the Microsoft Public License.
13 ' See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
14 ' All other rights reserved.
16 ' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
17 ' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
18 ' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
19 '***************************************************************************'
21 #Region
"Imports directives"
23 Imports System
.Collections
.Generic
29 Namespace VBEFEntityDataModel
.TablePerHierarchy
33 ' Test the query method in TPHClass
34 Public Shared
Sub TPHTest()
38 ' Query a list of people, print out the properties of Person,
39 ' Student and BusinessStudent
40 Public Shared
Sub Query()
41 Using context
As New EFTPHEntities()
43 Dim people
= From p
In context
.PersonSet _
47 Console
.WriteLine("Student {0} {1}", p
.LastName
, p
.FirstName
)
49 If TypeOf p Is Student
Then
50 Console
.WriteLine("EnrollmentDate: {0}", _
51 DirectCast(p
, Student
).EnrollmentDate
)
54 If TypeOf p Is BusinessStudent
Then
55 Console
.WriteLine("BusinessCredits: {0}", _
56 DirectCast(p
, BusinessStudent
).BusinessCredits
)